<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateSafety extends Migration{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up(){
        //防CC攻击 访问记录表
        Schema::create('cc_access', function(Blueprint $table){
            $table->engine = 'MyISAM';
            $table->comment = '访问记录表';
            $table->increments('id')->unsigned()->comment('自动增长主键');
            $table->string('ip', 100)->default('')->comment('访问IP');
            $table->string('url', 255)->default('')->comment('访问地址');
            $table->text('header')->default('')->comment('访问头信息(那个浏览器访问)');
            $table->timestamps();
        });

        //防CC攻击 黑名单记录表
        Schema::create('cc_blacklist', function(Blueprint $table){
            $table->engine = 'MyISAM';
            $table->comment = '黑名单记录表';
            $table->increments('id')->unsigned()->comment('自动增长主键');
            $table->string('ip', 100)->default('')->comment('添加黑名单IP');
            $table->timestamps();
        });

        //防CC攻击 访问设置表
        Schema::create('cc_setup', function(Blueprint $table){
            $table->engine = 'MyISAM';
            $table->comment = '访问设置表';
            $table->increments('id')->unsigned()->comment('自动增长主键');
            $table->tinyInteger('statistics')->unsigned()->default(0)->comment('统计模式(0代表关闭，1代表开启)');
            $table->tinyInteger('for_blacklist')->unsigned()->default(0)->comment('禁止黑名单访问模式(0代表关闭，1代表开启)');
            $table->tinyInteger('intelligent')->unsigned()->default(0)->comment('智能模式(0代表关闭，1代表开启)');
            $table->integer('number')->unsigned()->default(0)->comment('每分钟访问的次数(达到指定数添加到黑名单)');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down(){
        Schema::drop('cc_access');
        Schema::drop('cc_blacklist');
        Schema::drop('cc_setup');
    }
}
